<?php include('src/listEmail_cs.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href='css/coolMessage.css' type='text/css' rel='stylesheet' media='screen' />
<link rel="stylesheet" type="text/css" href="mopTip/mopTip-2.2.css">
<title>E-mails List :: First United Services LLC</title>
<script language="javaScript" type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="mopTip/mopTip-2.2.js"></script>
<script type="text/javascript" src="js/jquery.pngFix-1.2.js"></script>

<script language="javaScript" type="text/javascript" src="js/jquery.simplemodal.js"></script>
<script language="javaScript" type="text/javascript" src="js/coolMessage.js"></script>

<script language="javascript" type="text/javascript">
	
	function showMessage(show_msg){
		switch(show_msg){
			case 1://error
				coolMessage('error',"<?php echo $_SESSION["msg_cool"];?>", function (){ window.location.href='/listEmail.php'; });
			break;
			
			case 2://alert
				coolMessage('alert',"<?php echo $_SESSION["msg_cool"];?>", function (){ window.location.href='/listEmail.php'; });
			break;
			
			case 3://information
				coolMessage('information',"<?php echo $_SESSION["msg_cool"];?>", function (){ window.location.href='/listEmail.php'; });
			break;
			
			default:
				
			break;
		}
		return false;
	}
	
</script>

</head>
<body onload="javascript: showMessage(<?php echo $show_msg;?>)">
<?php $item_select = 7; include("menu.php");?><br />
<form name="form1" id="form1" method="post" action="">
    <div class="content_grv">
		<table class="tbl_list">
        	<tr>
            	<td colspan="6"><span class="title">EMAIL' LIST</span></td>
            </tr>
        	<tr>
            	<td colspan="6">
                	<table class="tbl_search">
                        <tr>
                            <td><input type="button" value="Send E-mail" class="button_grv" onclick="javascript: window.location.href='sendEmail.php'"/></td>
                            <td align="right"><input type="text" name="search" size="40" value="<?php echo $search;?>" class="text_grv" /><input type="submit" name="Submit" value="Search" class="button_grv"/></td>
                        </tr>
                    </table>
                </td>
            </tr>
            
            <?php if ( $totalFiles > 0){?>
            <tr>
            	<?php for ( $i = 0; $i < count ($ord_href); $i++ ){?>
            	<td class="item_head" width="<?php echo $item_width[$i];?>"><?php echo $ord_href[$i];?></td>
                <?php }?>
            </tr>
            <?php 
				$i = 0;
				while ( $i < count ($listEmail) ){
					$attachments = $listEmail[$i]->attachments;
					$countAttachments = count ($attachments);
					
					if($i%2==0)
						$class='item_a';
					else
						$class='item_b';
					
					if ( $countAttachments)
						$img = 'images/email_attach.png';
					else
						$img = 'images/email.png';
			?>
			<tr id="tr<?php echo $i;?>">
            	<td class="<?php echo $class;?>"><?php echo cambiarFormatoFecha( substr ($listEmail[$i]->email_date_create, 0, 10), 3);?></td>
                <td class="<?php echo $class;?>"><?php echo $listEmail[$i]->use_name.' '.$listEmail[$i]->use_lastname;?></td>
                <td class="<?php echo $class;?>"><?php echo $listEmail[$i]->use_email;?></td>
                <td class="<?php echo $class;?>"><?php echo $listEmail[$i]->email_to;?></td>
                <td class="<?php echo $class;?>"><?php echo $listEmail[$i]->email_subject;?></td>
                <td class="<?php echo $class;?>">
                <?php if ( $listEmail[$i]->email_content != '' || $countAttachments){?>
                    <a id="tooltip_<?php echo $i;?>"><img src="<?php echo $img;?>" width="16" height="16" /></a>
                    <div class="hidden">
                        <div id="tooltipshow_<?php echo $i;?>">
                            <table width="95%">
                                <tr>
                                    <td colspan="2"><?php echo nl2br($listEmail[$i]->email_content);?></td>
                                </tr>
							<?php if ($countAttachments){?>
                                <tr>
                                    <td width="10%" align="right" valign="top"><span class="lbl_gray">Attachments</span></td>
                                    <td>
	    	            	    <?php	
								for ($n=0; $n < $countAttachments; $n++){
									if ( file_exists('file_upload/email_attachment/'.$attachments[$n]->attach_rename)){
									
    		        	        ?> 
                            		<a href="/upload.php?f=file_upload/email_attachment/<?php echo $attachments[$n]->attach_rename;?>"><?php echo $attachments[$n]->attach_name;?></a>
	        		            <?php 
									if ( $n == ( $countAttachments -1 ) )
										echo '.';
									else
										echo ',';
									}
								}?>
									</td>
								</tr>
                            <?php
							}?>
                            </table>
                        </div>
                    </div>
                    <script language="javascript" type="text/javascript"> 
                        $("#tooltip_<?php echo $i;?>").mopTip({'w':500,'style':"overClick",'get':"#tooltipshow_<?php echo $i;?>"});
                    </script>
				<?php }?>
                </td>
            </tr>            
            <?php $i++; }?>
            
            <?php if ( $totalFiles > $cantidad){ ?>
            <tr>
            	<td colspan="6" align="center">
                	<table width="100%">
                    	<tr>
                        	<td align="center" width="25%"><a <?php if ($inicio == 0){ ?> class="lbl_gray" <?php } else {?> href="<?php echo $anterior; ?>"<?php } ?>>&lt;&lt;prev</a></td>
                            <td align="center" width="50%"><?php echo $paginas; ?></td>
                            <td align="center"><a <?php if ($totalPaginas == $paginaActual){ ?> class="lbl_gray" <?php } else {?> href="<?php echo $siguiente; ?>"<?php } ?>>next&gt;&gt;</a></td>
                        </tr>
                    </table>
                </td>
            </tr>            
            <?php } ?>
            
            <tr>
            	<td colspan="6" class="item_c"><?php echo $band_list;?></td>
            </tr>
            <?php }else{?>
            <tr>
            	<td colspan="6" class="no_data">No Data.</td>
            </tr>
            <?php }?>
        </table>
    </div>
</form>    
</body>
</html>
<?php include('divscoolmessage.php');?>